Skip to content

Improve CLI search output formatting and update docs#121

Merged
TianqiZhang merged 2 commits into
MicrosoftDocs:mainfrom
TianqiZhang:cli-output-formatting
Mar 12, 2026
Merged

Improve CLI search output formatting and update docs#121
TianqiZhang merged 2 commits into
MicrosoftDocs:mainfrom
TianqiZhang:cli-output-formatting

Conversation

@TianqiZhang
Copy link
Copy Markdown
Collaborator

  • Add formatters for search and code-search results: each result is displayed on its own numbered block instead of a raw JSON blob
  • Handle real MCP response fields (description, codeSnippet, link) and clean embedded metadata from code-search descriptions
  • Add --json flag to search and code-search for raw JSON piping
  • Update docs to reflect published npm package (@microsoft/learn-cli)
  • Rename 'Companion CLI' to 'Microsoft Learn CLI' across the repo

- Add formatters for search and code-search results: each result is
  displayed on its own numbered block instead of a raw JSON blob
- Handle real MCP response fields (description, codeSnippet, link)
  and clean embedded metadata from code-search descriptions
- Add --json flag to search and code-search for raw JSON piping
- Update docs to reflect published npm package (@microsoft/learn-cli)
- Rename 'Companion CLI' to 'Microsoft Learn CLI' across the repo

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 12, 2026 03:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improve CLI search/code-search UX by formatting results into readable numbered blocks (with optional raw JSON output) and update repository/docs branding to “Microsoft Learn CLI” and the published npm package name.

Changes:

  • Added result formatters for search and code-search, plus --json flag to output raw JSON.
  • Added unit tests for formatting behavior and updated CLI command tests to validate formatted output / --json.
  • Updated documentation and descriptions to reflect @microsoft/learn-cli and “Microsoft Learn CLI” naming.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/validate-repo.ps1 Updates validation script wording from “Companion CLI” to “CLI”.
cli/src/formatters/search-results.ts Introduces shared formatter logic for docs/code search outputs.
cli/src/commands/search.ts Adds --json option and formatted output for doc search.
cli/src/commands/code-search.ts Adds --json option and formatted output for code search.
cli/src/index.ts Updates CLI description text.
cli/package.json Updates package description text.
cli/test/unit/search-results.test.ts Adds unit tests for search/code-search formatting.
cli/test/unit/cli.test.ts Updates CLI tests for formatted output and --json behavior.
cli/README.md Updates installation/usage docs and documents --json.
README.md Updates root docs to reference @microsoft/learn-cli and new usage examples.
Comments suppressed due to low confidence (1)

cli/README.md:1

  • The command summary suggests code-search always requires --language <name>, but the CLI option is optional (and now also supports --json). To avoid confusing users, update the synopsis lines to reflect optional flags (e.g., code-search <query> [--language <name>] [--json] and search <query> [--json]).
# Microsoft Learn CLI

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/src/formatters/search-results.ts Outdated
Comment thread cli/src/formatters/search-results.ts
- Split formatSingleResult into formatDocsSearchResult and
  formatCodeSearchResult so code-search-specific cleanup (description
  metadata stripping, language suffix) does not apply to docs search
- Make metadata regex patterns tolerate optional whitespace after
  colons and optional leading whitespace before keys

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TianqiZhang TianqiZhang merged commit 45349c1 into MicrosoftDocs:main Mar 12, 2026
6 checks passed
@TianqiZhang TianqiZhang deleted the cli-output-formatting branch March 12, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants